<?php
namespace Common\Model;
use Common\Model\CommonModel;
class BbsCommentModel extends CommonModel
{

	protected $_validate = array(
		//array(验证字段,验证规则,错误提示,验证条件,附加规则,验证时间)
        array('user_id', 'require', '用户ID不能为空！', 1, 'regex', CommonModel:: MODEL_BOTH  ),
		array('bbs_id', 'require', '帖子ID不能为空！', 1, 'regex', CommonModel:: MODEL_BOTH  ),
		array('content', 'require', '内容不能为空！', 1, 'regex', CommonModel:: MODEL_BOTH ),
	);
	
	protected $_auto = array(
	    array('create_time','time',CommonModel:: MODEL_INSERT,'function'),
	);

	protected function _after_select(&$data) {
		parent::_after_select($data);
		
		foreach ($data as &$value){
            $value['avatar']=get_user_avatar($value['avatar']);
            $value['avatar_small']=get_user_avatar($value['avatar']);
            $value['images']=analysisImages($value['images']);
            $value['create_time']=date('Y-m-d H:i:s',$value['create_time']);
        }
        unset($value);
	}

	protected function _after_find(&$data) {
		parent::_after_find($data);
		
		$data['avatar']=get_user_avatar($data['avatar']);
        $data['avatar_small']=get_user_avatar($data['avatar']);
        $data['images']=analysisImages($data['images']);
        $data['create_time']=date('Y-m-d H:i:s',$data['create_time']);
	}
}

